#include <tuw_voronoi_graph/dxf_to_graph.h>
#include <boost/program_options.hpp>

namespace po = boost::program_options;

int main(int argc, char **argv)
{
    po::options_description description("usage");
    description.add_options()
            ("help,h", "Display help message")
            ("input,i", po::value<std::string>()->default_value("./segments.dxf"), "The path to the file")
            ("output,o", po::value<std::string>()->default_value("./graphs/segments"), "The output directory")
            ("width,w", po::value<float>()->default_value(0.6), "The width of a segments in meters")
            ("length,l", po::value<float>()->default_value(1.0), "The length of a segment in meters");
    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(description).run(), vm);
    po::notify(vm);
    if (vm.count("help")) std::cout << description << std::endl;
    else
    {
        std::string inpath = vm["input"].as<std::string>();
        std::string outpath = vm["output"].as<std::string>();
        if (outpath.back() != '/') outpath += "/";
        float length = vm["length"].as<float>();
        float width = vm["width"].as<float>();
        std::cout << "\tGenerating Graph from \"" << inpath << "\" with line_width: " << width
                  << " and minimum line_length: " << length << std::endl;
        tuw_graph::DxfToGraph dxf2graph;
        dxf2graph.parseGraph(inpath, length, width);
        dxf2graph.serializeGraph(outpath);
        std::cout << "\tSaving graph to \"" << outpath << "\"" << std::endl;
    }
    return 0;
}

